<?php
include('../classes/class.profile.php');
$myprofile = new profile();
$myprofile->set_userid($user);
$myprofile->set_page($pageid);
$test = new Listfiles('jpg', 'jpeg', 'png', 'gif');
$dir = $test->setDir('../../content/data/images/profiles/'.strtolower($_SESSION['username']).'/avatars');
$files = $test->getFiles();
?>

<form class="cms_form_edit" method="POST" enctype="multipart/form-data">
    <fieldset>
        <legend></legend>
        <?php
        if($myprofile->get_avatar() != "")
        {
            print('<img id="avatar" src="<?php print(DATA_PATH); ?>/images/profiles/'.strtolower($myprofile->get_userfolder()).'/avatars/'.strtolower($myprofile->get_avatar()).'" width="100px" title="'.$myprofile->get_avatarComment().'" />');
        }
        ?>
        <div class="clear"></div>
        <label for="profession">Profession</label>
        <input type="text" class="inputtxt" name="profession" value="<?php print($myprofile->get_profession()); ?>" />
        <br />
        <br />
        <label for="avatarList">Your avatar gallery</label>
        <select class="cms_dropdown" name="avatarList">
            <?php
            print('<option>Default</option>');
            foreach($files as $file){
                print('<option value="'.$file.'">'.$file.'</option>');
            }
            ?>
        </select>
        <br />
        <br />
        <label for="afbeelding">Upload new avatar <span class="grey">supports jpg, png and gif files</span></label>
        <input name="afbeelding" type="file" accept="image/jpeg" />
        <br />
        <br />
        <label for="img_comment">Avatar description</label>
        <textarea class="cms_txtarea" name="img_comment"><?php print($myprofile->get_avatarComment()); ?></textarea>
        <br />
        <br />
        <label for="os">Operating system of choice</label>
        <select class="cms_dropdown" name="os">
            <?php
            print('<option>'.$myprofile->get_os().'</option>');
            $osList = $myprofile->get_osList();
            foreach($osList as $os){
                print('<option value="'.$os['osname'].'">'.$os['osname'].'</option>');
            }
            ?>
        </select>
        <br />
        <br />
        <label for="aboutme">About me</label>
        <textarea class="cms_txtarea" name="aboutme" cols="0" rows="0"><?php print($myprofile->get_aboutMe()); ?></textarea>
        <br />
        <br />
        <label for="onMind">On my mind right now</label>
        <textarea class="cms_txtarea" name="onMind" cols="0" rows="0"><?php print($myprofile->get_onMind()); ?></textarea>
        <br />
        <br />
        <label for="feed">Last.fm Feed</label>
        <input type="text" class="inputtxt" name="feed" value="<?php print($myprofile->get_feed()); ?>" />
        <br />
        <br />
        <input type="checkbox" name="private" value="true" <?php print($myprofile->checked()) ?> /><p class="inline">Make this profile private</p>
        <br />
        <br />

    </fieldset>
    <fieldset>
        <legend></legend>
        <input type="submit" value="Confirm changes" />
        <input type="reset" value="Reset form" name="reset" />
    </fieldset>
</form>
<?php print($uploadError); ?>
<a href="page/page.php?page=profile&amp;user=<?php print($_SESSION['userId']); ?>">Return to your profile</a>